package daa.levelup.Library;

import java.util.Iterator;
import java.util.List;


public class TestDaoLibrary {

    private static DaoLibrary daoLibrary = new DaoLibrary();

    public static void main(String[] args)
    {

            System.setProperty("jdbc.drivers", "com.mysql.jdbc.driver");

            List<Book> fromDb = daoLibrary.getAllBooksFromDB();
            showUsers(fromDb);
            Book newBook = new Book(3, "UnmaterialBook");
            boolean res = daoLibrary.addBookToDB(newBook);
            System.out.println("RES: " + res);
            fromDb = daoLibrary.getAllBooksFromDB();
            showUsers(fromDb);

    }

   private static void showUsers(List<Book> all)
    {
        Iterator<Book> iter = all.iterator();
        Book tmp;
        while (iter.hasNext())
        {
            tmp = iter.next();
            System.out.println(tmp);
        }
    }
}
